<?php
ini_set('memory_limit', '-1');

if (!empty($_POST) && !empty($_POST['type']) && !empty($_POST['suffixes'])) {
	
	//测试
	echo "<pre>";
	//var_dump($_POST);
	
	//引入对应的类进行处理
	$type = $_POST['type'];
	if (file_exists("usr/{$type}.class.php")) {
		include("usr/{$type}.class.php");
	} else die('error: can not found class of this option');
	
	//变量存入
	if (!empty($_POST['num'])) { 
		$num = $_POST['num'];
	}
	$num = (empty($_POST['num']))?NULL:$_POST['num'];
	$domainName = (empty($_POST['domainName']))?NULL:$_POST['domainName'];	//域名 string
	$decorates = $_POST['decorates'];	//域名操作 array
	$suffixes = $_POST['suffixes']; 	//域名后缀

	$operation = (empty($_POST['num']))?new $type($domainName, $suffixes):new $type($_POST['num'], $suffixes);
		
	//域名生产
	$resDomains = array();
	foreach ($decorates as $decorate) {
		$result[$decorate] = $operation->$decorate();
		$resDomains = array_merge($resDomains, $result[$decorate]);
	}
	$resDomains = array_unique($resDomains);
	
	//var_dump($result);
	require_once 'usr/output/Output.php';
	$output = new Output($domainName, $resDomains);
	$output->toFile();
}
?>